<!DOCTYPE html>
<html lang="en">
<!--header-->
<include file="Public:header"/>
<!--header-->
<style>
    .table > thead > tr > th, .table > tbody > tr > th, .table > tfoot > tr > th, .table > thead > tr > td, .table > tbody > tr > td, .table > tfoot > tr > td{
        padding: 11px;
    }
    .table-striped > tbody > tr:nth-child(odd) > td{
        padding-left: 60px;
    }
    tbody  td{
        font-size: 16px;
    }
</style>
<section id="main-content">
    <section class="wrapper">
        <h3><i class="fa fa-angle-right"></i> 核销用户信息</h3>
        <!-- BASIC FORM ELELEMNTS -->
        <div class="row mt">
            <div class="col-lg-12">
                <div class="form-panel" style="height: 500px">
                    <h4 class="mb"><i class="fa"></i>
                        <a onclick="history.go(-1)" class="external-event label label-success" style="margin-left: 40px; float: left;margin-top: 15px;">返回</a>
                    </h4>
                    <br>
                    <table class="table table-striped table-advance table-hover" style="text-align: left">
                        <!--<h4 style="display: block;margin-top: 45px"><i class="fa fa-angle-right"></i> 用户详细信息：</h4>
                        <hr>-->
                        <thead>
                        <tr>
                            <th>头像</th>
                            <th>姓名：</th>
                            <th>性别：</th>
                            <th>电话：</th>
                            <th>鲜花数：</th>
                            <th>积分数：</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>
                                <if condition = "$list['avatar'] == NULL">
                                    <a class="fancybox" href="__PUBLIC__/img/wutu.png">
                                        <img class="img-responsive" src="__PUBLIC__/img/wutu.png" style="width: 60px;height: 60px;border-radius: 50%">
                                    </a>
                                    <else/>
                                    <a class="fancybox" href="{$list.avatar}">
                                        <img class="img-responsive" src="{$list.avatar}" style="width: 60px;height: 60px;border-radius: 50%">
                                    </a>
                                </if>
                            </td>
                            <td>{$list.name}</td>
                             <td>
                                 <if condition="$user.sex == 0">
                                     未知
                                 </if>
                                 <if condition="$user.sex == 1">
                                     男
                                 </if>
                                 <if condition="$user.sex == 2">
                                     女
                                 </if>
                             </td>
                            <td>{$list.phone}</td>
                            <td><b style="color: red">{$list.flowers}</b></td>
                            <td><b style="color: red">{$list.covers}</b></td>
                        </tr>
                        </tbody>
                    </table>
                    <form id="myForm" class="form-horizontal style-form" method="post"  enctype="multipart/form-data">
                        <div class="form-group" >
                            <label class="col-sm-2 col-sm-2 control-label">核销类别</label>
                            <div class="col-sm-10">
                                <select  id="lei" class="form-control">
                                    <option value="0">请选择核销类别</option>
                                    <option value="1">鲜花核销</option>
                                    <option value="2">积分核销</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group" >
                            <label class="col-sm-2 col-sm-2 control-label">核销量</label>
                            <div class="col-sm-10">
                                <input id="he_one"    type="number"   class="form-control" placeholder="请输入核销量">
                            </div>
                        </div>
                        <input type="hidden"  id="user_id" value="{$list.id}">
                        <input type="hidden"  id="covers" value="{$list.covers}">
                        <input type="hidden"  id="flowers" value="{$list.flowers}">
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label"></label>
                            <div class="col-sm-10">
                                <input  type="button" id="tianjia" class="btn btn-theme" value="保存" style="width: 150px;margin-left: 60px">
                                <input  type="reset" class="btn btn-warning" value="重置" style="width: 150px">
                            </div>
                        </div>
                    </form>
                </div>
            </div><!-- col-lg-12-->
        </div><!-- /row -->
    </section>
</section>

</section>
<!--footer-->
<include file="Public:footer"/>
<!--footer-->
<script type="text/javascript" src="__PUBLIC__/ui/lib/layer/2.4/layer.js"></script>
<script type="text/javascript">
    $(function() {
        //    fancybox
        jQuery(".fancybox").fancybox();
    });
</script>
<script>
    //custom select box
    $(function(){
        $('select.styled').customSelect();
    });

    $("#tianjia").click(function () {
        var lei  = $("#lei").val();
        var id   = $("#user_id").val();
        var one  = $("#he_one").val();
        var flowers = $("#flowers").val();
        var covers = $("#covers").val();
        /*var yu   = one%100;
        if(parseInt(one) < 100 || parseInt(yu) > 0){
            layer.open({
                title: '核销提示',
                content: "请输入核销数大于100或者是100的整数倍！",
            });
        }else{*/

        if(one < 1 || lei < 1){
            layer.open({
                title: '核销提示',
                content: "请选择核销类别或输入核销数！",
            });
        }else{
             pan = false;
            if(lei == 1){   //核销鲜花
                if(flowers > one){pan = true;}
            }
            if(lei == 2){   //核销积分
                if(covers > one){pan = true;}
            }
            if(!pan){
                layer.open({
                    title: '核销提示',
                    content: "输入核销数量超过核销上限！",
                });
            }else{
                layer.confirm('确认核销吗？确定后不可更改', {
                    title: '核销提示：',
                    btn: ['确定'] //可以无限个按钮
                }, function(index, layero){
                    $.ajax({
                        type:"post",
                        data:{id:id,one:one,lei:lei},
                        url:"{:U('he_xiao')}",
                        success:function (res) {
                            if(res == 3){
                                layer.open({
                                    title: '核销提示',
                                    content: "核销成功",
                                });
                                location.href="__APP__/Dashboard/User/ji_he/id/"+id;
                            }
                            if(res == 1){
                                layer.open({
                                    title: '核销提示'
                                    ,content: "请输入核销积分"
                                });
                            }
                            if(res == 2){
                                layer.open({
                                    title: ''
                                    ,content: "核销失败"
                                });
                            }
                            if(res == 4){
                                layer.open({
                                    title: ''
                                    ,content: "核销失败"
                                });
                            }
                        }
                    })
                });
            }
        }
    })
</script>

</body>
</html>
